import QtQuick 2.12
import QtQuick.Window 2.12
import QtMultimedia 5.12

import "qrc:/"

Window {
    width: 338
    height: 500
    visible: true
    title: qsTr("Tetris")
    minimumWidth: 338
    minimumHeight: 500

    Item {
        id: root
        anchors.fill: parent

        Component.onCompleted: {
            showMenuPage()
        }

        Loader {
            id: panelLoader
            anchors.fill: parent

            function setSourceComponent(vehicleComponent) {
                panelLoader.sourceComponent = sourceComponent
            }
        }

        Component{
            id:gamePage
            GamePage {
                anchors.fill: parent
                Component.onCompleted: {
                    menuClicked.connect(root.showMenuPage)
                }
            }
        }

        Component{
            id:menuPage
            MenuPage {
                anchors.fill: parent
                Component.onCompleted: {
                    startClicked.connect(root.showGamePage)
                }
            }
        }

        // 游戏界面
        function showGamePage()
        {
            panelLoader.setSourceComponent(gamePage)
        }

        // 主菜单
        function showMenuPage()//常规设置
        {
            panelLoader.setSourceComponent(menuPage)
        }
    }

}
